package Lab01;
import java.util.Scanner;
/**
 * Created by dell on 2017/10/15.
 */
public class Test08 {
    public static void main(String[] args) {
        System.out.println("请猜这个数字");
        int realNumber=(int)(Math.random()*100)+1;//随机给客户分配1-100的数字
        int yourGuess=0;                          //赋初值
        Scanner reader=new Scanner(System.in);    //创建一个对象
        System.out.println("请输入你猜测的数字：");
        yourGuess=reader.nextInt();                //reader对象调用nextInt(),读取用户输入的数
        while(yourGuess!=realNumber)
        {
            if(yourGuess>realNumber){
                System.out.println("猜大了");
                yourGuess=reader.nextInt();
            }
            else if(yourGuess<realNumber){
                System.out.println("猜小了");
                yourGuess=reader.nextInt();
            }
        }
        System.out.println("猜对了");
    }
}
